package com.glory.wxelectricitypda.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.CheckBox;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.wxelectricitypda.R;
import com.glory.wxelectricitypda.bean.FTPittedSubmitBean;

import java.util.ArrayList;
import java.util.List;

public class FTChangeMantissaAdapter extends BaseQuickAdapter<FTPittedSubmitBean.LOTLISTDTO, BaseViewHolder> {

    private ArrayList<Integer> lotList = new ArrayList<>();

    public FTChangeMantissaAdapter(@Nullable List<FTPittedSubmitBean.LOTLISTDTO> data) {
        super(R.layout.adapter_ft_change_mantissa,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, FTPittedSubmitBean.LOTLISTDTO item) {
        helper.setText(R.id.position,String.valueOf(helper.getPosition()+1));
        helper.setText(R.id.lotID,item.getLOTID());
        helper.setText(R.id.mainQTY,String.valueOf(item.getMAINQTY()));
        CheckBox checkbox = helper.getView(R.id.checkbox);
        checkbox.setTag(helper.getAdapterPosition());
        checkbox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean isChecked = ((CheckBox) v).isChecked();
                if (isChecked) {
                    lotList.add(helper.getAdapterPosition());
                } else {
                    lotList.remove(helper.getAdapterPosition());
                }
            }
        });
    }

    public ArrayList<Integer> getLotList() {
        return this.lotList;
    }
}
